SSRS subscription: Run for previous month?
I have a few subscriptions I need to set up that should display the previous month's data. The parameters as of right now are only two date fields, is there a way to set it up in the subscription to only use last month's dates?
July 25th, 2012 9:15am
Hi,
You'll need to set the default dates to use last month's date in BIDS and deploy the report. When the subscription runs, it will pick up whatever was setup as default.
Hope this helps!Shahfaisal Muhammed http://shahfaisalmuhammed.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2012 9:30am
I can change the default value of the parameters in SSRS on the deployed report, but I'm not even sure how to tell it to use the last month. What would the expression be to get the very first and last date of the month?
July 25th, 2012 9:43am
Please see below. You'll need to set the default value for the parameters in the parameter properties.
Set First date of current month
=DateSerial(Year(Now()), Month(Now()), 1)
Set Last date of current month
=DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Now()), Month(Now()), 1))))
Shahfaisal Muhammed http://shahfaisalmuhammed.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2012 9:50am
Hi Meef,
Thanks for your posting.
If it is an On-Demend report, we can directly specify parameters values when we create the subscription. In this way, the report processes according to the parameters we have specified when the subscription begins to run.
If the report renders from snapshot, the subscription cannot overwrite the parameters values defined for the snapshot. In this condition, you can refer to Shahfaisal's suggestion to filter the report data on the report level. To do this, we
can set the default value of the parameters as follows:
The first day of last month:
=DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, "1/1/1900", Today())-2, "1/1/1900")
The last day of last month:
=DateAdd(DateInterval.Day,-1*DatePart(DateInterval.Day,Today()),Today())
or
=DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, "1/1/1900", Today())-1, "1/1/1900"))
If you have any questions, please feel free to let me known.
Regards,
Mike YinMike Yin
TechNet Community Support
August 1st, 2012 2:22am
Hi Meef,
Thanks for your posting.
If it is an On-Demend report, we can directly specify parameters values when we create the subscription. In this way, the report processes according to the parameters we have specified when the subscription begins to run.
If the report renders from snapshot, the subscription cannot overwrite the parameters values defined for the snapshot. In this condition, you can refer to Shahfaisal's suggestion to filter the report data on the report level. To do this, we
can set the default value of the parameters as follows:
The first day of last month:
=DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, "1/1/1900", Today())-2, "1/1/1900")
The last day of last month:
=DateAdd(DateInterval.Day,-1*DatePart(DateInterval.Day,Today()),Today())
or
=DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, "1/1/1900", Today())-1, "1/1/1900"))
If you have any questions, please feel free to let me known.
Regards,
Mike YinMike Yin
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
August 1st, 2012 2:24am
I see what you mean about "on demand", you're talking about if you create a report within SSRS directly instead of within the BIDS environment. So basically my only solution is copying the reports and setting defaults.
When I set the parameters to Mike's suggestions, as I try to run the report I get this message:
"Overload resolution failed because no accessible 'DateDiff' can be called without a narrowing conversion"
There's also a syntax error in your code around the "Today())" area according to Visual Studio but I don't know what it's looking for.
Suggestions?
August 14th, 2012 8:48am
Hi meef,
Thanks for your posting.
Based on the error message, the issue can occur due to data type of some variable in your DateDiff function code. For more information, please see the following threads with a similar topic:
DateDiff Problem in VB 2008DateAdd Trouble
Hope this helps.
Regards,
Mike YinMike Yin
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2012 9:35am
Both of those seem to deal with VB code for the solutions... My data type for both parameters is set as "Date/Time" and that's the only thing I gathered to check from those links.
August 14th, 2012 12:59pm